import { userStore } from "@/store/index";
import { storeBindingsBehavior } from "mobx-miniprogram-bindings";
import { router } from "@/util/index";
Page({
  behaviors: [storeBindingsBehavior],
  storeBindings: {
    store: userStore,
    fields: ["islogin", "userInfo"],
  },
  data: {
    money: 0,
    loading: true,
    loadingText: "加载中...",
  },
  contact(e) {
    console.log(e.currentTarget.dataset.uid);
  },
  goPage(e) {
    router.navigateTo(e.currentTarget.dataset.url);
  },
  navigateToWithdrawal() {
    router.navigateTo("./upmoney/index");
  },
  navigateToIdleItems() {
    router.navigateTo("./myitems/index");
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad() {},
  adLoad() {
    this.setData({
      loading: false,
    });
  },
  adError() {
    this.setData({
      loadingText: "暂无匹配到广告",
    });
    console.log(this.data.loadingText);
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.setData({
      money: (this.data.userInfo.pine_cone_balance / 100).toFixed(2),
    });
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {},
});
